{{!

  Copyright (c) Facebook, Inc. and its affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

}}{{!

Definitions for constant values. These are included from the struct.pyx file
and define Python objects that can be imported from the end-user's Python
file.

}}
{{#constant:type}}{{!
}}
{{#type:bool?}}
{{constant:name}} = {{#constant:value}}{{!
  }}{{#value:nonzero?}}True{{/value:nonzero?}}{{!
  }}{{^value:nonzero?}}False{{/value:nonzero?}}{{/constant:value}}
{{/type:bool?}}
{{#type:byte?}}
{{constant:name}} = {{#constant:value}}{{value:integerValue}}{{/constant:value}}
{{/type:byte?}}
{{#type:i16?}}
{{constant:name}} = {{#constant:value}}{{value:integerValue}}{{/constant:value}}
{{/type:i16?}}
{{#type:i32?}}
{{constant:name}} = {{#constant:value}}{{value:integerValue}}{{/constant:value}}
{{/type:i32?}}
{{#type:i64?}}
{{constant:name}} = {{#constant:value}}{{value:integerValue}}{{/constant:value}}
{{/type:i64?}}
{{#type:double?}}
{{constant:name}} = {{#constant:value}}{{!
}}{{#value:integer?}}{{value:integerValue}}.0{{/value:integer?}}{{!
}}{{#value:double?}}{{value:doubleValue}}{{/value:double?}}{{!
}}{{/constant:value}}
{{/type:double?}}
{{#type:float?}}
{{constant:name}} = {{#constant:value}}{{!
}}{{#value:integer?}}{{value:integerValue}}.0{{/value:integer?}}{{!
}}{{#value:double?}}{{value:doubleValue}}{{/value:double?}}{{!
}}{{/constant:value}}
{{/type:float?}}
{{#type:string?}}
{{constant:name}} = c{{constant:name}}().decode('UTF-8')
{{/type:string?}}
{{#type:binary?}}
{{constant:name}} = <bytes> c{{constant:name}}()
{{/type:binary?}}
{{! We take the constant structs/containers and build a non-const shared_ptr
    as required by the thrift-py3 wrapper api, generally this is a terrible
    idea as constant() is an r-value, and removing the const qualifier is dangerous
    but we *promise* in the thrift-py3 api to never change objects.
}}
{{#type:struct?}}
{{constant:name}} = {{> types/CythonPythonType}}.create(constant_shared_ptr({{!
    }}c{{constant:name}}()))
{{/type:struct?}}
{{#type:container?}}
{{constant:name}} = {{> types/CythonPythonType}}.create(constant_shared_ptr({{!
    }}c{{constant:name}}()))
{{/type:container?}}
{{#type:enum}}
{{constant:name}} = {{#type:externalProgram?}}{{> common/ModulePath}}.{{!
    }}{{/type:externalProgram?}}{{enum:name}}(<int> (c{{constant:name}}()))
{{/type:enum}}
{{/constant:type}}
